package com.example.yichuangyun.dialog;

import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import com.example.yichuangyun.R;
import com.example.yichuangyun.databinding.PopMoreScreenBinding;
import com.example.yichuangyun.model.company.CompanyListParamsModel;
import com.example.yichuangyun.model.company.MoreScreenModel;
import com.example.yichuangyun.model.company.ScreenModel;
import com.example.yichuangyun.mvvm.ui.adapter.MoreScreenAdapter;
import com.example.yichuangyun.utils.ToastHelper;
import com.example.yichuangyun.utils.producttreelist.ProductNodeModel;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 更多筛选条件
 */
@SuppressLint("NotifyDataSetChanged")
public abstract class MoreScreenPopupWindow extends PopupWindow {

    private final PopMoreScreenBinding binding;
    private final List<MoreScreenModel> data = new ArrayList<>();
    private final Context context;
    private final CompanyListParamsModel companyListParamsModel;
    /**
     * 注册资本
     */
    private final List<CompanyListParamsModel.RangeModel> registCapis = new ArrayList<>();
    /**
     * 成立年限
     */
    private final List<CompanyListParamsModel.RangeModel> startDates = new ArrayList<>();
    /**
     * 企业类型
     */
    private final List<Integer> econKinds = new ArrayList<>();
    /**
     * 参保人数
     */
    private final List<CompanyListParamsModel.RangeModel> yanglaobxNums = new ArrayList<>();
    /**
     * 实缴资本
     */
    private final List<CompanyListParamsModel.RangeModel> actualCapis = new ArrayList<>();
    /**
     * 组织机构
     */
    private final List<String> typeNews = new ArrayList<>();
    /**
     * 资本类型
     */
    private final List<String> currencyUnits = new ArrayList<>();
    /**
     * 专利类型
     */
    private final List<String> patentsRelationsNewType = new ArrayList<>();
    /**
     * 联系方式
     */
    private final List<Integer> contactTypeList = new ArrayList<>();

    private final List<String> licenseNameList = new ArrayList<>();
    private final List<String> notLicenseNameList = new ArrayList<>();

    public MoreScreenPopupWindow(Context context) {
        binding = PopMoreScreenBinding.inflate(LayoutInflater.from(context));
        this.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        this.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
        this.setFocusable(true);
        setContentView(binding.getRoot());
        this.context = context;
        companyListParamsModel = new CompanyListParamsModel();
        initTypeData();
        setListener();
    }

    private void initTypeData() {
        // 注册资本
        List<ScreenModel> zczbList = new ArrayList<>();
        zczbList.add(new ScreenModel(context.getString(R.string.reg_capital1), String.valueOf(0), String.valueOf(100)));
        zczbList.add(new ScreenModel(context.getString(R.string.reg_capital2), String.valueOf(100), String.valueOf(500)));
        zczbList.add(new ScreenModel(context.getString(R.string.reg_capital3), String.valueOf(500), String.valueOf(1000)));
        zczbList.add(new ScreenModel(context.getString(R.string.reg_capital4), String.valueOf(1000), String.valueOf(3000)));
        zczbList.add(new ScreenModel(context.getString(R.string.reg_capital5), String.valueOf(3000), String.valueOf(5000)));
        zczbList.add(new ScreenModel(context.getString(R.string.reg_capital6), String.valueOf(5000), ""));

        // 成立时间
        List<ScreenModel> clsjList = new ArrayList<>();
        clsjList.add(new ScreenModel(context.getString(R.string.set_up_date1), String.valueOf(0), String.valueOf(1)));
        clsjList.add(new ScreenModel(context.getString(R.string.set_up_date2), String.valueOf(1), String.valueOf(5)));
        clsjList.add(new ScreenModel(context.getString(R.string.set_up_date3), String.valueOf(5), String.valueOf(10)));
        clsjList.add(new ScreenModel(context.getString(R.string.set_up_date4), String.valueOf(10), String.valueOf(15)));
        clsjList.add(new ScreenModel(context.getString(R.string.set_up_date5), String.valueOf(15), ""));

        // 企业类型
        List<ScreenModel> qylxList = new ArrayList<>();
        qylxList.add(new ScreenModel(context.getString(R.string.company_type1), 1));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type2), 2));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type3), 3));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type4), 4));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type5), 5));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type6), 6));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type7), 7));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type8), 8));
        qylxList.add(new ScreenModel(context.getString(R.string.company_type9), 9));
        qylxList.add(new ScreenModel(context.getString(R.string.other), 10));

        // 参保人数
        List<ScreenModel> cbrsList = new ArrayList<>();
        cbrsList.add(new ScreenModel(context.getString(R.string.insure_count1), String.valueOf(0), String.valueOf(50)));
        cbrsList.add(new ScreenModel(context.getString(R.string.insure_count2), String.valueOf(50), String.valueOf(99)));
        cbrsList.add(new ScreenModel(context.getString(R.string.insure_count3), String.valueOf(100), String.valueOf(499)));
        cbrsList.add(new ScreenModel(context.getString(R.string.insure_count4), String.valueOf(500), ""));

        // 纳税类型
        List<ScreenModel> nslxList = new ArrayList<>();
        nslxList.add(new ScreenModel(context.getString(R.string.pay_taxes_type1), 1));
        nslxList.add(new ScreenModel(context.getString(R.string.pay_taxes_type2), 0));

        // 纳税信用
        List<ScreenModel> nsxyList = new ArrayList<>();
        nsxyList.add(new ScreenModel(context.getString(R.string.pay_taxes_credit1), 1));
        nsxyList.add(new ScreenModel(context.getString(R.string.pay_taxes_credit2), 0));

        // 实缴资本
        List<ScreenModel> sjzbList = new ArrayList<>();
        sjzbList.add(new ScreenModel(context.getString(R.string.reg_capital1), String.valueOf(0), String.valueOf(100)));
        sjzbList.add(new ScreenModel(context.getString(R.string.reg_capital2), String.valueOf(100), String.valueOf(500)));
        sjzbList.add(new ScreenModel(context.getString(R.string.reg_capital3), String.valueOf(500), String.valueOf(1000)));
        sjzbList.add(new ScreenModel(context.getString(R.string.reg_capital4), String.valueOf(1000), String.valueOf(3000)));
        sjzbList.add(new ScreenModel(context.getString(R.string.reg_capital5), String.valueOf(3000), String.valueOf(5000)));
        sjzbList.add(new ScreenModel(context.getString(R.string.reg_capital6), String.valueOf(5000), ""));

        // 组织机构
        List<ScreenModel> zzjgList = new ArrayList<>();
        zzjgList.add(new ScreenModel(context.getString(R.string.org1), "01"));
        zzjgList.add(new ScreenModel(context.getString(R.string.org2), "02"));
        zzjgList.add(new ScreenModel(context.getString(R.string.org3), "03"));
        zzjgList.add(new ScreenModel(context.getString(R.string.org4), "04"));
        zzjgList.add(new ScreenModel(context.getString(R.string.org5), "05"));

        // 资本类型
        List<ScreenModel> zblxList = new ArrayList<>();
        zblxList.add(new ScreenModel(context.getString(R.string.rmb), "CNY"));
        zblxList.add(new ScreenModel(context.getString(R.string.dollar), "USD"));
        zblxList.add(new ScreenModel(context.getString(R.string.other), "other"));

        // 专利类型
        List<ScreenModel> zllxList = new ArrayList<>();
        zllxList.add(new ScreenModel(context.getString(R.string.patent_type1), "fmzl"));
        zllxList.add(new ScreenModel(context.getString(R.string.patent_type2), "syxx"));
        zllxList.add(new ScreenModel(context.getString(R.string.patent_type3), "wgsj"));

        // 联系方式
        List<ScreenModel> lxfsList = new ArrayList<>();
        lxfsList.add(new ScreenModel(context.getString(R.string.phone_y), 1));
        lxfsList.add(new ScreenModel(context.getString(R.string.fixed_phone_y), 2));
        lxfsList.add(new ScreenModel(context.getString(R.string.email_y), 3));

        // 化妆品生产许可
        List<ScreenModel> hzpList = new ArrayList<>();
        hzpList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        hzpList.add(new ScreenModel(context.getString(R.string.hzp_y), 1));
        hzpList.add(new ScreenModel(context.getString(R.string.hzp_n), 0));

        // 药品经营企业
        List<ScreenModel> ypjyList = new ArrayList<>();
        ypjyList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        ypjyList.add(new ScreenModel(context.getString(R.string.ypjy_y), 1));
        ypjyList.add(new ScreenModel(context.getString(R.string.ypjy_n), 0));

        // 药品生产企业
        List<ScreenModel> ypscList = new ArrayList<>();
        ypscList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        ypscList.add(new ScreenModel(context.getString(R.string.ypsc_y), 1));
        ypscList.add(new ScreenModel(context.getString(R.string.ypsc_n), 0));

        // 房地产开发
        List<ScreenModel> fdcList = new ArrayList<>();
        fdcList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        fdcList.add(new ScreenModel(context.getString(R.string.fdc_y), 1));
        fdcList.add(new ScreenModel(context.getString(R.string.fdc_n), 0));

        // 食品经营许可
        List<ScreenModel> spjyList = new ArrayList<>();
        spjyList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        spjyList.add(new ScreenModel(context.getString(R.string.spjy_y), 1));
        spjyList.add(new ScreenModel(context.getString(R.string.spjy_n), 0));

        // 食品生产许可
        List<ScreenModel> spscList = new ArrayList<>();
        spscList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        spscList.add(new ScreenModel(context.getString(R.string.spsc_y), 1));
        spscList.add(new ScreenModel(context.getString(R.string.spsc_n), 0));

        // 医疗器械经营许可
        List<ScreenModel> ylqxList = new ArrayList<>();
        ylqxList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        ylqxList.add(new ScreenModel(context.getString(R.string.ylqx_y), 1));
        ylqxList.add(new ScreenModel(context.getString(R.string.ylqx_n), 0));

        // 安全生产许可
        List<ScreenModel> aqscList = new ArrayList<>();
        aqscList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        aqscList.add(new ScreenModel(context.getString(R.string.aqsc_y), 1));
        aqscList.add(new ScreenModel(context.getString(R.string.aqsc_n), 0));

        // 排污许可
        List<ScreenModel> pwxkList = new ArrayList<>();
        pwxkList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        pwxkList.add(new ScreenModel(context.getString(R.string.pw_y), 1));
        pwxkList.add(new ScreenModel(context.getString(R.string.pw_n), 0));

        // 采矿权
        List<ScreenModel> ckqList = new ArrayList<>();
        ckqList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        ckqList.add(new ScreenModel(context.getString(R.string.ckq_y), 1));
        ckqList.add(new ScreenModel(context.getString(R.string.ckq_n), 0));

        // 探矿权
        List<ScreenModel> tkqList = new ArrayList<>();
        tkqList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        tkqList.add(new ScreenModel(context.getString(R.string.tkq_y), 1));
        tkqList.add(new ScreenModel(context.getString(R.string.tkq_n), 0));

        // 建筑资质
        List<ScreenModel> jzzzList = new ArrayList<>();
        jzzzList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        jzzzList.add(new ScreenModel(context.getString(R.string.jzzz_y), 1));
        jzzzList.add(new ScreenModel(context.getString(R.string.jzzz_n), 0));

        // 失信信息
        List<ScreenModel> sxxxList = new ArrayList<>();
        sxxxList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        sxxxList.add(new ScreenModel(context.getString(R.string.sxxx_y), 1));
        sxxxList.add(new ScreenModel(context.getString(R.string.sxxx_n), 0));

        // 行政处罚
        List<ScreenModel> xzcfList = new ArrayList<>();
        xzcfList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        xzcfList.add(new ScreenModel(context.getString(R.string.xzcf_y), 1));
        xzcfList.add(new ScreenModel(context.getString(R.string.xzcf_n), 0));

        // 清算信息
        List<ScreenModel> qsxxList = new ArrayList<>();
        qsxxList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        qsxxList.add(new ScreenModel(context.getString(R.string.qsxx_y), 1));
        qsxxList.add(new ScreenModel(context.getString(R.string.qsxx_n), 0));

        // 动产抵押
        List<ScreenModel> dcdyList = new ArrayList<>();
        dcdyList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        dcdyList.add(new ScreenModel(context.getString(R.string.dcdy_y), 1));
        dcdyList.add(new ScreenModel(context.getString(R.string.dcdy_n), 0));

        // 经营异常
        List<ScreenModel> jyycList = new ArrayList<>();
        jyycList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        jyycList.add(new ScreenModel(context.getString(R.string.jyyc_y), 1));
        jyycList.add(new ScreenModel(context.getString(R.string.jyyc_n), 0));

        // 变更信息
        List<ScreenModel> bgxxList = new ArrayList<>();
        bgxxList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        bgxxList.add(new ScreenModel(context.getString(R.string.bgxx_y), 1));
        bgxxList.add(new ScreenModel(context.getString(R.string.bgxx_n), 0));

        // 商标信息
        List<ScreenModel> sbxxList = new ArrayList<>();
        sbxxList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        sbxxList.add(new ScreenModel(context.getString(R.string.sbxx_y), 1));
        sbxxList.add(new ScreenModel(context.getString(R.string.sbxx_n), 0));

        // 软件著作权
        List<ScreenModel> rjzzList = new ArrayList<>();
        rjzzList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        rjzzList.add(new ScreenModel(context.getString(R.string.rjzz_y), 1));
        rjzzList.add(new ScreenModel(context.getString(R.string.rjzz_n), 0));

        // 作品著作权
        List<ScreenModel> zpzzList = new ArrayList<>();
        zpzzList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        zpzzList.add(new ScreenModel(context.getString(R.string.zpzz_y), 1));
        zpzzList.add(new ScreenModel(context.getString(R.string.zpzz_n), 0));

        // 专利信息
        List<ScreenModel> zlxxList = new ArrayList<>();
        zlxxList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        zlxxList.add(new ScreenModel(context.getString(R.string.zlxx_y), 1));
        zlxxList.add(new ScreenModel(context.getString(R.string.zlxx_n), 0));

        // 对外投资
        List<ScreenModel> dwtzList = new ArrayList<>();
        dwtzList.add(new ScreenModel(context.getString(R.string.no_limit), null));
        dwtzList.add(new ScreenModel(context.getString(R.string.dwtz_y), 1));
        dwtzList.add(new ScreenModel(context.getString(R.string.dwtz_n), 0));

        data.add(new MoreScreenModel(context.getString(R.string.zczb), zczbList, 1));
        data.add(new MoreScreenModel(context.getString(R.string.clsj), clsjList, 2));
        data.add(new MoreScreenModel(context.getString(R.string.qylx), qylxList, 3));
        data.add(new MoreScreenModel(context.getString(R.string.cbrs), cbrsList, 4));
        data.add(new MoreScreenModel(context.getString(R.string.nslx), nslxList, 5));
        data.add(new MoreScreenModel(context.getString(R.string.nsxy), nsxyList, 6));
        data.add(new MoreScreenModel(context.getString(R.string.sjzb), sjzbList, 7));
        data.add(new MoreScreenModel(context.getString(R.string.zzjg), zzjgList, 8));
        data.add(new MoreScreenModel(context.getString(R.string.zblx), zblxList, 9));
        data.add(new MoreScreenModel(context.getString(R.string.zllx), zllxList, 10));
        data.add(new MoreScreenModel(context.getString(R.string.contact_way), lxfsList, 33));
        data.add(new MoreScreenModel(context.getString(R.string.hzp), hzpList, 11));
        data.add(new MoreScreenModel(context.getString(R.string.ypjy), ypjyList, 12));
        data.add(new MoreScreenModel(context.getString(R.string.ypsc), ypscList, 13));
        data.add(new MoreScreenModel(context.getString(R.string.fdc), fdcList, 14));
        data.add(new MoreScreenModel(context.getString(R.string.spjy), spjyList, 15));
        data.add(new MoreScreenModel(context.getString(R.string.spsc), spscList, 16));
        data.add(new MoreScreenModel(context.getString(R.string.ylqx), ylqxList, 17));
        data.add(new MoreScreenModel(context.getString(R.string.aqsc), aqscList, 18));
        data.add(new MoreScreenModel(context.getString(R.string.pwxk), pwxkList, 19));
        data.add(new MoreScreenModel(context.getString(R.string.ckq), ckqList, 20));
        data.add(new MoreScreenModel(context.getString(R.string.tkq), tkqList, 21));
        data.add(new MoreScreenModel(context.getString(R.string.jzzz), jzzzList, 22));
        data.add(new MoreScreenModel(context.getString(R.string.sxxx), sxxxList, 23));
        data.add(new MoreScreenModel(context.getString(R.string.xzcf), xzcfList, 24));
        data.add(new MoreScreenModel(context.getString(R.string.qsxx), qsxxList, 25));
        data.add(new MoreScreenModel(context.getString(R.string.dcdy), dcdyList, 26));
        data.add(new MoreScreenModel(context.getString(R.string.jyyc), jyycList, 27));
        data.add(new MoreScreenModel(context.getString(R.string.bgxx), bgxxList, 28));
        data.add(new MoreScreenModel(context.getString(R.string.sbxx), sbxxList, 29));
        data.add(new MoreScreenModel(context.getString(R.string.rjzzq), rjzzList, 30));
        data.add(new MoreScreenModel(context.getString(R.string.zpzzq), zpzzList, 31));
        data.add(new MoreScreenModel(context.getString(R.string.zlxx), zlxxList, 32));
        data.add(new MoreScreenModel(context.getString(R.string.dwtz), dwtzList, 34));
    }

    private void setListener() {
        MoreScreenAdapter moreScreenAdapter = new MoreScreenAdapter(context, data);
        binding.recyclerView.setAdapter(moreScreenAdapter);

        binding.includeBtn.tvConfirm.setOnClickListener(view -> {
            for (MoreScreenModel moreScreenModel : data) {
                switch (moreScreenModel.getType()) {
                    case 1: // 注册资本
                        registCapis.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                registCapis.add(new CompanyListParamsModel.RangeModel(screenModel.getMinNum(), screenModel.getMaxNum()));
                            }
                        }
                        companyListParamsModel.setRegistCapis(registCapis);
                        break;
                    case 2: // 成立年限
                        startDates.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                startDates.add(new CompanyListParamsModel.RangeModel(screenModel.getMinNum(), screenModel.getMaxNum()));
                            }
                        }
                        if (!TextUtils.isEmpty(moreScreenModel.getStartDate()) && TextUtils.isEmpty(moreScreenModel.getEndDate())) {
                            ToastHelper.show(context.getString(R.string.end_time));
                            return;
                        }
                        if (TextUtils.isEmpty(moreScreenModel.getStartDate()) && !TextUtils.isEmpty(moreScreenModel.getEndDate())) {
                            ToastHelper.show(context.getString(R.string.start_time));
                            return;
                        }
                        if (!TextUtils.isEmpty(moreScreenModel.getStartDate()) && !TextUtils.isEmpty(moreScreenModel.getEndDate())) {
                            startDates.add(new CompanyListParamsModel.RangeModel(moreScreenModel.getStartDate(), moreScreenModel.getEndDate(), 1));
                        }
                        companyListParamsModel.setStartDates(startDates);
                        break;
                    case 3: // 企业类型
                        econKinds.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                econKinds.add(screenModel.getCode());
                            }
                        }
                        companyListParamsModel.setEconKinds(econKinds);
                        break;
                    case 4: // 参保人数
                        yanglaobxNums.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                yanglaobxNums.add(new CompanyListParamsModel.RangeModel(screenModel.getMinNum(), screenModel.getMaxNum()));
                            }
                        }
                        companyListParamsModel.setYanglaobxNums(yanglaobxNums);
                        break;
                    case 5: // 纳税类型
                        companyListParamsModel.setTaxTypeState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setTaxTypeState(screenModel.getCode());
                            }
                        }
                        break;
                    case 6: // 纳税信用
                        companyListParamsModel.setTaxPayingState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setTaxPayingState(screenModel.getCode());
                            }
                        }
                        break;
                    case 7: // 实缴资本
                        actualCapis.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                actualCapis.add(new CompanyListParamsModel.RangeModel(screenModel.getMinNum(), screenModel.getMaxNum()));
                            }
                        }
                        companyListParamsModel.setActualCapis(actualCapis);
                        break;
                    case 8: // 组织机构
                        typeNews.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                typeNews.add(screenModel.getType());
                            }
                        }
                        companyListParamsModel.setTypeNews(typeNews);
                        break;
                    case 9: // 资本类型
                        currencyUnits.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                currencyUnits.add(screenModel.getType());
                            }
                        }
                        companyListParamsModel.setCurrencyUnits(currencyUnits);
                        break;
                    case 10: // 专利类型
                        patentsRelationsNewType.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                patentsRelationsNewType.add(screenModel.getType());
                            }
                        }
                        companyListParamsModel.setPatentsRelationsNewType(patentsRelationsNewType);
                        break;
                    case 11: // 化妆品生产许可
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.hzp)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.hzp)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (!screenModel.getName().equals(context.getString(R.string.no_limit)) && screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.hzp_y))) {
                                    licenseNameList.add(context.getString(R.string.hzp));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.hzp));
                                }
                                break;
                            }
                        }
                        break;
                    case 12: // 药品经营企业
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.ypjy)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.ypjy)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.ypjy_y))) {
                                    licenseNameList.add(context.getString(R.string.ypjy));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.ypjy));
                                }
                                break;
                            }
                        }
                        break;
                    case 13: // 药品生产企业
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.ypsc)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.ypsc)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.ypsc_y))) {
                                    licenseNameList.add(context.getString(R.string.ypsc));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.ypsc));
                                }
                                break;
                            }
                        }
                        break;
                    case 14: // 房地产开发
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.fdc)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.fdc)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.fdc_y))) {
                                    licenseNameList.add(context.getString(R.string.fdc));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.fdc));
                                }
                                break;
                            }
                        }
                        break;
                    case 15: // 食品经营许可
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.spjy)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.spjy)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.spjy_y))) {
                                    licenseNameList.add(context.getString(R.string.spjy));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.spjy));
                                }
                                break;
                            }
                        }
                        break;
                    case 16: // 食品生产许可
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.spsc)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.spsc)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.spsc_y))) {
                                    licenseNameList.add(context.getString(R.string.spsc));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.spsc));
                                }
                                break;
                            }
                        }
                        break;
                    case 17: // 医疗器械经营许可
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.ylqx)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.ylqx)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.ylqx_y))) {
                                    licenseNameList.add(context.getString(R.string.ylqx));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.ylqx));
                                }
                                break;
                            }
                        }
                        break;
                    case 18: // 安全生产许可
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.aqsc)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.aqsc)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.aqsc_y))) {
                                    licenseNameList.add(context.getString(R.string.aqsc));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.aqsc));
                                }
                                break;
                            }
                        }
                        break;
                    case 19: // 排污许可
                        licenseNameList.removeIf(s -> s.equals(context.getString(R.string.pwxk)));
                        notLicenseNameList.removeIf(s -> s.equals(context.getString(R.string.pwxk)));
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                if (screenModel.getName().equals(context.getString(R.string.pw_y))) {
                                    licenseNameList.add(context.getString(R.string.pwxk));
                                } else {
                                    notLicenseNameList.add(context.getString(R.string.pwxk));
                                }
                                break;
                            }
                        }
                        break;
                    case 20: // 采矿权
                        companyListParamsModel.setMiningLicenseState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setMiningLicenseState(screenModel.getCode());
                            }
                        }
                        break;
                    case 21: // 探矿权
                        companyListParamsModel.setMiningExplorationState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setMiningExplorationState(screenModel.getCode());
                            }
                        }
                        break;
                    case 22: // 建筑资质
                        companyListParamsModel.setBuildingState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setBuildingState(screenModel.getCode());
                            }
                        }
                        break;
                    case 23: // 失信信息
                        companyListParamsModel.setSeriousIllegalState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setSeriousIllegalState(screenModel.getCode());
                            }
                        }
                        break;
                    case 24: // 行政处罚
                        companyListParamsModel.setAdministrativePunishmentState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setAdministrativePunishmentState(screenModel.getCode());
                            }
                        }
                        break;
                    case 25: // 清算信息
                        companyListParamsModel.setClearAccountState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setClearAccountState(screenModel.getCode());
                            }
                        }
                        break;
                    case 26: // 动产抵押
                        companyListParamsModel.setMortgagesState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setMortgagesState(screenModel.getCode());
                            }
                        }
                        break;
                    case 27: // 经营异常
                        companyListParamsModel.setAbnormalState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setAbnormalState(screenModel.getCode());
                            }
                        }
                        break;
                    case 28: // 变更信息
                        companyListParamsModel.setChangeRecordsState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setChangeRecordsState(screenModel.getCode());
                            }
                        }
                        break;
                    case 29: // 商标信息
                        companyListParamsModel.setTrademarkInfoState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setTrademarkInfoState(screenModel.getCode());
                            }
                        }
                        break;
                    case 30: // 软件著作权
                        companyListParamsModel.setCopyrightPState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setCopyrightPState(screenModel.getCode());
                            }
                        }
                        break;
                    case 31: // 作品著作权
                        companyListParamsModel.setCopyrightSState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setCopyrightSState(screenModel.getCode());
                            }
                        }
                        break;
                    case 32: // 专利信息
                        companyListParamsModel.setPatentsRelationsState(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setPatentsRelationsState(screenModel.getCode());
                            }
                        }
                        break;
                    case 33: // 联系方式
                        contactTypeList.clear();
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                contactTypeList.add(screenModel.getCode());
                            }
                        }
                        companyListParamsModel.setContactTypeList(contactTypeList);
                        break;
                    case 34: // 对外投资
                        companyListParamsModel.setIsExistsInvestment(null);
                        for (ScreenModel screenModel : moreScreenModel.getTags()) {
                            if (screenModel.isSelect()) {
                                companyListParamsModel.setIsExistsInvestment(screenModel.getCode());
                            }
                        }
                        break;
                }
            }
            companyListParamsModel.setLicenseNameList(licenseNameList);
            companyListParamsModel.setNotLicenseNameList(notLicenseNameList);
            if (!TextUtils.isEmpty(data.get(0).getMinCapital()) || !TextUtils.isEmpty(data.get(0).getMaxCapital())) {
                int min = TextUtils.isEmpty(data.get(0).getMinCapital()) ? 0 : Integer.parseInt(data.get(0).getMinCapital());
                String max = TextUtils.isEmpty(data.get(0).getMaxCapital()) ? "" : data.get(0).getMaxCapital();
                if (!max.isEmpty() && min > Integer.parseInt(max)) {
                    ToastHelper.show(context.getString(R.string.value_hint_reg));
                    return;
                }
                registCapis.add(new CompanyListParamsModel.RangeModel(String.valueOf(min), max));
            }

            if (!TextUtils.isEmpty(data.get(5).getMinCapital()) || !TextUtils.isEmpty(data.get(5).getMaxCapital())) {
                int min = TextUtils.isEmpty(data.get(5).getMinCapital()) ? 0 : Integer.parseInt(data.get(5).getMinCapital());
                String max = TextUtils.isEmpty(data.get(5).getMaxCapital()) ? "" : data.get(5).getMaxCapital();
                if (!max.isEmpty() && min > Integer.parseInt(max)) {
                    ToastHelper.show(context.getString(R.string.value_hint_aut));
                    return;
                }
                actualCapis.add(new CompanyListParamsModel.RangeModel(String.valueOf(min), max));
            }
            confirm(companyListParamsModel);
            dismiss();
        });

        binding.includeBtn.view.setOnClickListener(v -> dismiss());

        binding.includeBtn.tvReset.setOnClickListener(view -> {
            registCapis.clear();
            startDates.clear();
            econKinds.clear();
            yanglaobxNums.clear();
            actualCapis.clear();
            typeNews.clear();
            currencyUnits.clear();
            patentsRelationsNewType.clear();
            contactTypeList.clear();
            licenseNameList.clear();
            notLicenseNameList.clear();
            companyListParamsModel.setTaxTypeState(null);
            companyListParamsModel.setTaxPayingState(null);
            companyListParamsModel.setMiningLicenseState(null);
            companyListParamsModel.setMiningExplorationState(null);
            companyListParamsModel.setBuildingState(null);
            companyListParamsModel.setSeriousIllegalState(null);
            companyListParamsModel.setAdministrativePunishmentState(null);
            companyListParamsModel.setClearAccountState(null);
            companyListParamsModel.setMortgagesState(null);
            companyListParamsModel.setAbnormalState(null);
            companyListParamsModel.setChangeRecordsState(null);
            companyListParamsModel.setTrademarkInfoState(null);
            companyListParamsModel.setCopyrightPState(null);
            companyListParamsModel.setCopyrightSState(null);
            companyListParamsModel.setPatentsRelationsState(null);
            companyListParamsModel.setIsExistsInvestment(null);
            for (MoreScreenModel moreScreenModel : data) {
                moreScreenModel.setMinCapital("");
                moreScreenModel.setMaxCapital("");
                moreScreenModel.setStartDate("");
                moreScreenModel.setEndDate("");
                for (ScreenModel screenModel : moreScreenModel.getTags()) {
                    screenModel.setSelect(false);
                }
            }
            moreScreenAdapter.notifyDataSetChanged();

            confirm(companyListParamsModel);
            dismiss();
        });
    }

    public abstract void confirm(CompanyListParamsModel companyListParamsModel);
}
